import 'package:flutter/material.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:umeng_apm_sdk/umeng_apm_sdk.dart';

import '../../../widgets/base/qkd_text.dart';

class DataLeftList extends StatelessWidget {
  final List<String> titles;
  final int selectIndex;
  final Function(int) onSelectIndex;
  DataLeftList(this.titles, this.selectIndex, this.onSelectIndex, {super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colours.greyF5F7FA,
      width: 80,
      child: MediaQuery.removePadding(
        context: context,
        removeTop: true,
        child: ListView.builder(
          controller: ApmScrollController(),
          itemCount: titles.length,
          itemBuilder: (context, index) => GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () => onSelectIndex(index),
            child: Stack(
              children: [
                Container(
                  height: 60,
                  padding: const EdgeInsets.symmetric(horizontal: 4),
                  color: selectIndex == index
                    ? Colours.greyFD : Colours.transparent,
                  alignment: Alignment.center,
                  child: QkdText(
                    titles[index],
                    textAlign: TextAlign.center,
                    fontSize: 13,
                    color: selectIndex == index
                      ? Colours.main : Colours.text,
                  ),
                ),
                Visibility(
                  visible: selectIndex == index,
                  child: Positioned(
                    left: 0,
                    top: 18,
                    bottom: 18,
                    child: Container(
                      width: 3,
                      height: 24,
                      decoration: const BoxDecoration(
                        color: Colours.main,
                        borderRadius: BorderRadius.horizontal(
                          right: Radius.circular(3)
                        )
                      )
                    )
                  )
                )
              ]
            )
          )
        )
      )
    );
  }
}
